package com.sailors.common.task.sdk.core.handle.factory;

import com.sailors.common.task.sdk.core.handle.CommonTaskHandler;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * Handler factory
 *
 * @description: 执行者工厂方法
 * @author: cyj
 * @date 2022 -11-25 15:02:03
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class HandlerFactory {

    /**
     * Gets instance *
     *
     * @param tclass tclass
     * @return the instance
     */
    public static CommonTaskHandler getInstance(Class<? extends CommonTaskHandler> tclass) {
        if (tclass.getCanonicalName().equals(FileTaskHandler.class.getCanonicalName())) {
            return FileTaskHandler.getSingleton();
        } else if (tclass.getCanonicalName().equals(FileTaskTemplateHandler.class.getCanonicalName())) {
            return FileTaskTemplateHandler.getSingleton();
        }
        throw new RuntimeException("无法获取对象");
    }

}
